package com.hxkj.controller.article;

import com.hxkj.domain.po.Companyinfo;
import com.hxkj.service.article.CompanyInfoService;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * 合作公司控制层
 * <p>
 * Created by yaosy on 2018年6月14日19:28:33
 */
@RestController
@RequestMapping("/company")
public class CompanyInfoController {

    @Autowired
    private CompanyInfoService companyInfoService;


    /**
     * 新增合作公司
     *
     * @param companyinfo
     * @throws Exception
     */
    @RequestMapping(value = "/save")
    public Callable<ResultMessageStruct> save(@ModelAttribute Companyinfo companyinfo) throws Exception {
        return ()-> companyInfoService.save(companyinfo);
    }



    /**
     * 获取合作公司列表
     *
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getlist")
    public Callable<ResultPageStruct<Companyinfo>> getlist(@ModelAttribute Companyinfo companyinfo, @ModelAttribute PageTo pageParam) throws Exception {
        return () ->companyInfoService.getList(companyinfo,pageParam);
    }


    /**
     * 删除合作公司
     *
     * @param companyinfo
     * @throws Exception
     */
    @RequestMapping(value = "/remove")
    public Callable<ResultMessageStruct> remove(@ModelAttribute Companyinfo companyinfo) throws Exception{
        return () -> companyInfoService.remove(companyinfo);
    }

    /**
     * 获取单条合作公司数据
     *
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/get")
    public Callable<Companyinfo> get(@ModelAttribute Companyinfo companyinfo) throws Exception {
        return () ->companyInfoService.get(companyinfo);
    }

    /**
     * 修改单条合作公司数据
     *
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/modify")
    public void modify(@ModelAttribute Companyinfo companyinfo) throws Exception {
        companyInfoService.modify(companyinfo);
    }


    /**
     *排序
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sort")
    public Callable<ResultMessageStruct>  sort(@ModelAttribute Companyinfo companyinfo) throws Exception {
        return () -> companyInfoService.sort(companyinfo);
    }
}
